<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        	function printHollowDiamond(n) {
			var str = "";

			for (var i = 1; i <= 2*n+1; i++) {
				// 计算每行空格和星号的数量
				var spaceNum = Math.abs(n - i);
				var starNum = 2*n - 2*spaceNum;

				// 拼接每行的字符串
				var rowStr = "";
				for (var j = 1; j <= spaceNum; j++) {
					rowStr += "&nbsp;";
				}
				for (var k = 1; k <= starNum; k++) {
					if (k == 1 || k == starNum-1) {
						rowStr += "*";
					} else {
						rowStr += "&nbsp;";
					}
				}

				str += rowStr + "<br/>";
			}
			console.log(str)
			document.write(str);
		}

		// 调用函数打印空心棱形
		printHollowDiamond(3);
    </script>
</head>
<body>
    
</body>
</html>